<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script type="text/html" id="tpl-user">
        <div>姓名：{{name}}</div>
        <div>年龄：{{ age }}</div>
        <div>性别：{{ gender}}</div>
        <div>住址：{{address }}</div>
    </script>
</head>

<body>
    <div id="info"></div>
    <!-- 引入我们自己实现的mini版模板引擎 -->
    <script type="text/javascript" src="./js/my-template.js"></script>
    <script type="text/javascript">
        // 测试数据
        var data = {
            name: 'zs',
            age: 28,
            gender: '男',
            address: '北京顺义马坡',
        };
        // 通过模板引擎进行编译
        var ret = myTemplate('tpl-user', data);
        console.log(ret);
        var div = document.getElementById('info');
        div.innerHTML = ret;
    </script>
</body>

</html>